package com.ruoyi.tccs.tccs_major_judge.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.tccs.tccs_major_judge.utils.judgeResult.tccsResult;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.tccs.tccs_major_judge.domain.TccsMajorJudge;
import com.ruoyi.tccs.tccs_major_judge.service.ITccsMajorJudgeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * tccs判断Controller
 *
 * @author RenZhengYang
 * @date 2024-04-08
 */
@RestController
@RequestMapping("/tccs/tccs_major_judge")
public class TccsMajorJudgeController extends BaseController
{
    @Autowired
    private ITccsMajorJudgeService tccsMajorJudgeService;

    @Autowired
    private tccsResult tccsResult;

    /**
     * 查询tccs判断列表
     */
    @PreAuthorize("@ss.hasPermi('tccs:tccs_major_judge:list')")
    @GetMapping("/list")
    public TableDataInfo list(TccsMajorJudge tccsMajorJudge)
    {
        startPage();
        List<TccsMajorJudge> list = tccsMajorJudgeService.selectTccsMajorJudgeList(tccsMajorJudge);
        return getDataTable(list);
    }

    /**
     * 导出tccs判断列表
     */
    @PreAuthorize("@ss.hasPermi('tccs:tccs_major_judge:export')")
    @Log(title = "tccs判断", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TccsMajorJudge tccsMajorJudge)
    {
        List<TccsMajorJudge> list = tccsMajorJudgeService.selectTccsMajorJudgeList(tccsMajorJudge);
        ExcelUtil<TccsMajorJudge> util = new ExcelUtil<TccsMajorJudge>(TccsMajorJudge.class);
        util.exportExcel(response, list, "tccs判断数据");
    }

    /**
     * 获取tccs判断详细信息
     */
    @PreAuthorize("@ss.hasPermi('tccs:tccs_major_judge:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tccsMajorJudgeService.selectTccsMajorJudgeById(id));
    }

    /**
     * 新增tccs判断
     */
    @PreAuthorize("@ss.hasPermi('tccs:tccs_major_judge:add')")
    @Log(title = "tccs判断", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TccsMajorJudge tccsMajorJudge)
    {
        tccsMajorJudge.setCreateBy(getUsername());
        tccsResult.JudgeResult(tccsMajorJudge);
        return toAjax(tccsMajorJudgeService.insertTccsMajorJudge(tccsMajorJudge));
    }

    /**
     * 修改tccs判断
     */
    @PreAuthorize("@ss.hasPermi('tccs:tccs_major_judge:edit')")
    @Log(title = "tccs判断", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TccsMajorJudge tccsMajorJudge)
    {
        tccsMajorJudge.setUpdateBy(getUsername());
        tccsResult.JudgeResult(tccsMajorJudge);
        return toAjax(tccsMajorJudgeService.updateTccsMajorJudge(tccsMajorJudge));
    }

    /**
     * 删除tccs判断
     */
    @PreAuthorize("@ss.hasPermi('tccs:tccs_major_judge:remove')")
    @Log(title = "tccs判断", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tccsMajorJudgeService.deleteTccsMajorJudgeByIds(ids));
    }
}
